<?php

namespace Beerus\Modules\Designer\Actions;

use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;
use Doraemon\model\DesignerEvaluation;


class CancelFold extends RowAction
{
    public $name = '取消折叠';
    const TOAST_ALERT = '确认取消该评级的折叠嘛?取消后将把该条评价展示!';

    public function handle($id)
    {
        $update_data['is_fold'] = DesignerEvaluation::FOLD_NORMAL;
        $evaluate_result = DesignerEvaluation::updateInfo($id,$update_data);
        if ($evaluate_result){
            return $this->response()->success('取消折叠该评价成功(*^__^*)')->refresh();
        }else{
            return $this->response()->error('取消折叠该评价失败,请稍后重试o(TωT)o');
        }

    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}
